package cn.leftsite.java11;

import java.util.ArrayList;

class Garbage {
    private double d1 = 1;
    private double d2 = 2;

    @Override
    public void finalize() throws Throwable {
        System.out.println(this + " collecting");
    }
}

public class EpsilonDemo {
    public static void main(String[] args) {

        var list = new ArrayList<Garbage>();
        boolean flag = true;
        int count = 0;
        while (flag){
            list.add(new Garbage());
            if (count++ == 500){
                list.clear();
            }
        }
    }
}
